package Demo5;

class Singleton3{
    private static volatile Singleton3 instance;

    public static synchronized Singleton3 getInstance(){
        if(instance==null){
            synchronized (Singleton3.class){
                if(instance==null){
                    instance=new Singleton3();
                }
            }
        }
        return instance;
    }
    private Singleton3() {
    }
}

class Singleton4{
private static class SingletonHolder{
private final static Singleton4 INSTANCE=new Singleton4();
}

public static Singleton4 getInstance(){
    return SingletonHolder.INSTANCE;
}
    private Singleton4() {
    }
}



public class Main9 {



}
